<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- React 底层核心库 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/react/18.2.0/umd/react.development.js"></script>
    <!-- React 操作 Dom 库，类似 JQuery -->
    <script src="https://cdn.bootcdn.net/ajax/libs/react-dom/18.2.0/umd/react-dom.development.min.js"></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
</head>

<body>
    <div id="app">

    </div>

    <div id="app2">

    </div>

    <script type="text/babel">
        class Hello extends React.Component {
            state = {
                value: '123'
            }

            // 受控组件
            render() {
                return <div>
                    受控组件

                    <input type="text" value={this.state.value} />
                </div>
            }
        }
        ReactDOM.createRoot(document.querySelector('#app')).render(<Hello />);

        class Hello2 extends React.Component {
            state = {
                value: '123'
            }

            handleChange = (e) => {
                console.log('e', e);
                this.setState({
                    value: e.target.value
                })
            }
            // 受控组件
            render() {
                return <div>
                    非受控组件

                    <input type="text" onChange={this.handleChange} value={this.state.value} />
                    <p>
                        {this.state.value}
                    </p>
                </div>
            }
        }
        ReactDOM.createRoot(document.querySelector('#app2')).render(<Hello2 />);
    </script>
</body>

</html>